﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Styx.Common;

namespace TuanHAPriest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void DesperatePrayer_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DesperatePrayer = (int) DesperatePrayer.Value;
        }

        private void DispersionMana_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DispersionMana = (int) DispersionMana.Value;
        }

        private void DispersionHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DispersionHP = (int) DispersionHP.Value;
        }

        private void HaloMin_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.HaloMin = (int) HaloMin.Value;
        }

        private void HaloMax_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.HaloMax = (int) HaloMax.Value;
        }

        private void HaloSafeCheck_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.HaloSafeCheck = HaloSafeCheck.Checked;
        }

        private void HealthstonePercent_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.HealthstonePercent = (int) HealthstonePercent.Value;
        }

        private void MindFlayDuration_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.MindFlayDuration = (int)MindFlayDuration.Value;
        }

        private void MindSearClipping_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.MindSearClipping = (int) MindSearClipping.Value;
        }

        private void MindSearStartonUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.MindSearStartonUnit = (int) MindSearStartonUnit.Value;
        }

        private void SWPRefresh_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SWPRefresh = (int) SWPRefresh.Value;
        }

        private void VampiricEmbracePercent_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.VampiricEmbracePercent = (int) VampiricEmbracePercent.Value;
        }

        private void VampiricTouchRefresh_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.VampiricTouchRefresh = (int) VampiricTouchRefresh.Value;
        }

        private void FaceAuto_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.FaceAuto = FaceAuto.Checked;
        }

        private void FadeAuto_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.FadeAuto = FadeAuto.Checked;
        }

        private void InnerFire_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.InnerFire = InnerFire.Checked;
        }

        private void PowerWordFortitude_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.PowerWordFortitude = PowerWordFortitude.Checked;
        }

        private void PowerWordShield_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.PowerWordShield = PowerWordShield.Checked;
        }

        private void ShadowfiendAuto_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ShadowfiendAuto = ShadowfiendAuto.Checked;
        }

        private void Shadowform_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.Shadowform = Shadowform.Checked;
        }

        private void ShadowWordPainMoving_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ShadowWordPainMoving = ShadowWordPainMoving.Checked;
        }

        private void ManaSWP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ManaSWP = (int)ManaSWP.Value;
        }

        private void SPauseKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (SPauseKey.SelectedIndex == i)
                {
                    THSettings.Instance.SPauseKey = i;
                }
            }
        }

        private void SAoEKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (SAoEKey.SelectedIndex == i)
                {
                    THSettings.Instance.SAOEKey = i;
                }
            }
        }

        private void SHaloKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (SHaloKey.SelectedIndex == i)
                {
                    THSettings.Instance.SHaloKey = i;
                }
            }

        }

        private void SModeKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (SModeKey.SelectedIndex == i)
                {
                    THSettings.Instance.SModeKey = i;
                }
            }

        }


        private void Form1_Load(object sender, EventArgs e)
        {
            if (
                File.Exists(Utilities.AssemblyDirectory +
                            @"\Routines\TuanHAShadowPriest\TuanHAShadowPriest.jpg"))
            {
                pictureBox1.ImageLocation = Utilities.AssemblyDirectory +
                                            @"\Routines\TuanHAShadowPriest\TuanHAShadowPriest.jpg";
            }

            DesperatePrayer.Value = THSettings.Instance.DesperatePrayer;
            DispersionMana.Value = THSettings.Instance.DispersionMana;
            DispersionHP.Value = THSettings.Instance.DispersionHP;
            HaloMin.Value = THSettings.Instance.HaloMin;
            HaloMax.Value = THSettings.Instance.HaloMax;
            HaloSafeCheck.Checked = THSettings.Instance.HaloSafeCheck;
            HealthstonePercent.Value = THSettings.Instance.HealthstonePercent;
            MindFlayDuration.Value = THSettings.Instance.MindFlayDuration;
            MindSearClipping.Value = THSettings.Instance.MindSearClipping;
            MindSearStartonUnit.Value = THSettings.Instance.MindSearStartonUnit;
            SWPRefresh.Value = THSettings.Instance.SWPRefresh;
            VampiricEmbracePercent.Value = THSettings.Instance.VampiricEmbracePercent;
            VampiricTouchRefresh.Value = THSettings.Instance.VampiricTouchRefresh;
            FaceAuto.Checked = THSettings.Instance.FaceAuto;
            FadeAuto.Checked = THSettings.Instance.FadeAuto;
            InnerFire.Checked = THSettings.Instance.InnerFire;
            PowerWordFortitude.Checked = THSettings.Instance.PowerWordFortitude;
            PowerWordShield.Checked = THSettings.Instance.PowerWordShield;
            ShadowfiendAuto.Checked = THSettings.Instance.ShadowfiendAuto;
            Shadowform.Checked = THSettings.Instance.Shadowform;
            ShadowWordPainMoving.Checked = THSettings.Instance.ShadowWordPainMoving;
            ManaSWP.Value = THSettings.Instance.ManaSWP;
            SAoEKey.SelectedIndex = THSettings.Instance.SAOEKey;
            SPauseKey.SelectedIndex = THSettings.Instance.SPauseKey;
            SHaloKey.SelectedIndex = THSettings.Instance.SHaloKey;
            SModeKey.SelectedIndex = THSettings.Instance.SModeKey;
        }

        private void bDefault_Click(object sender, EventArgs e)
        {
            DesperatePrayer.Value = 30;
            DispersionMana.Value = 10;
            DispersionHP.Value = 20;
            HaloMin.Value = 22;
            HaloMax.Value = 28;
            HaloSafeCheck.Checked = true;
            HealthstonePercent.Value = 20;
            MindFlayDuration.Value = 2000;
            MindSearClipping.Value = 1000;
            MindSearStartonUnit.Value = 6;
            SWPRefresh.Value = 3000;
            VampiricEmbracePercent.Value = 70;
            VampiricTouchRefresh.Value = 3000;
            FaceAuto.Checked = true;
            FadeAuto.Checked = true;
            InnerFire.Checked = true;
            PowerWordFortitude.Checked = true;
            PowerWordShield.Checked = true;
            ShadowfiendAuto.Checked = true;
            Shadowform.Checked = true;
            ManaSWP.Value = 60;
            ShadowWordPainMoving.Checked = true;
            SAoEKey.SelectedIndex = 1;
            SPauseKey.SelectedIndex = 16;
            SHaloKey.SelectedIndex = 8;
            SModeKey.SelectedIndex = 18;
        }

        private void bSave_Click(object sender, EventArgs e)
        {
            THSettings.Instance.Save();
            Logging.Write("----------------------------------");
            Logging.Write("TuanHA Shadow Priest Settings have been saved");
        }

        private void bOK_Click(object sender, EventArgs e)
        {
            THSettings.Instance.Save();
            Logging.Write("----------------------------------");
            Logging.Write("TuanHA Shadow Priest Settings have been saved");
            Close();
        }

        private void label32_Click(object sender, EventArgs e)
        {

        }





    }
}